﻿#pragma once

// Get the RPC header file
#include "../RootRpcInterface/RootRpcInterface.h"

// Transient object types
enum TransientObjectType
{
	TRANSIENT_MUTEX,
	TRANSIENT_EVENT,
	TRANSIENT_SEMAPHORE,
	TRANSIENT_WAITABLE_TIMER,
	TRANSIENT_JOB,
	TRANSIENT_FILE_MAPPING,
	TRANSIENT_NAMED_PIPE,
	TRANSIENT_MAILSLOT,
	TRANSIENT_ALPC,
	TRANSIENT_RPC,
	TRANSIENT_WNF,
	TRANSIENT_TEMPLATE,
	TRANSIENT_PRIVATE
};

// Retrieves a security descriptor for passing to RPC endpoint and interface functions
EXTERN_C __declspec(dllimport) NTSTATUS QueryTransientObjectSecurityDescriptor(
	TransientObjectType type, PWSTR name, PSECURITY_DESCRIPTOR * sd);
// Frees the memory containing the retrieved security descriptor
EXTERN_C __declspec(dllimport) void FreeTransientObjectSecurityDescriptor(
	PSECURITY_DESCRIPTOR sd);

// Security callback function for the RPC interface
RPC_STATUS CALLBACK SecurityCallback(RPC_IF_HANDLE iface, PVOID context);

// Logging functions. For now, they just go to stdout/stderr
void LogError(PCWSTR message, ...);
void LogWarning(PCWSTR message, ...);
void LogInfo(PCWSTR message, ...);
void LogVerbose(PCWSTR message, ...);
void LogDebug(PCWSTR message, ...);

WINERR StartRpcServer();
WINERR StopRpcServer(BOOL WaitForCalls = TRUE);
WINERR ServiceStop(WINERR win32err = NO_ERROR);
